class ValleyersController < ApplicationController
  layout 'base.html'
  
  def new
    @valleyer = Valleyer.new
  end

  def create
    @valleyer = Valleyer.new(params[:valleyer])
    if @valleyer.save
      session[:current_valleyer_id] = @valleyer.id
      redirect_to home_url(:default)
    else
      render :new
    end
  end

  def show
    @valleyer = Valleyer.find params[:id]
    @html_title = @valleyer.nick_name + '的主页'
    @html_description = @valleyer.nick_name + '的主页'
    @articles = Article.paginate_by_author_id @valleyer.id, :page => params[:log_page_number], :per_page => 5, :order => "created_at desc"
    @reships = Reship.paginate_by_author_id @valleyer.id, :page => params[:reship_page_number], :per_page => 5, :order => "created_at desc"
    
    @post = Post.new :valleyer_id => params[:id],
      :created_by_valleyer_id => current_valleyer_id
    @documet_types = default_category + @valleyer.documet_types
    @mood = Mood.new :valleyer_id => current_valleyer_id
    @browse_record = BrowseRecord.create(
      :valleyer_id => @valleyer.id,
      :browser_id => current_valleyer_id
    )
  end

  def authorize

  end
end
